factory design pattern in java with realtime example